package com.beantest.service;

import com.beantest.event.CustomEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Service;

@Service
public class EventPublisherService {

    @Autowired
    private ApplicationEventPublisher eventPublisher;

    public void publishCustomEvent(String message) {
        System.out.println("发布自定义事件，消息内容: " + message);
        eventPublisher.publishEvent(new CustomEvent(this, message));
    }
}
